<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<script type="text/javascript">

    $(function () {
        initSelectAjax("/sysUserController/userGlobalStatus.html", $('#status'), true);
        initLoadData('/deptController/detailDept.html', $('#deptIdFrom').text());
        $('#editFunction').click(function () {
            parent.$.messager.progress({
                title: '提示',
                text: '数据处理中，请稍后....'
            });
            var isValid = $('#form').form('validate');
            if (isValid) {
                parent.$.messager.progress('close');
                var postData = $('#form').serializeJson();
                $.ajax({
                    url: "${pageContext.request.contextPath}/deptController/updateDept.html",
                    type: "post",
                    dataType: "json",
                    data: postData,
                    success: function (result) {
                        parent.$.messager.progress('close');
                        if (result && isSuccess(result.result)) {
                            parent.$.modalDialog.openner_treeGrid.datagrid('getPager').pagination('select');
                            parent.$.modalDialog.handler.dialog('close');
                            return false;
                        }else{
                            parent.$.messager.alert('提示', result.result + " " + result.message, 'info');
                            return false;
                        }
                        return false;
                    },
                    error: function (result) {
//			internalError();
                        templateInternalError(result.responseText);
                        parent.$.messager.progress('close');
                        return false;
                    }
                });
            } else {
                parent.$.messager.progress('close');
                return isValid;
            }
        });
        <%--$('#form').form({--%>
            <%--url: '${pageContext.request.contextPath}/deptController/updateDept.html',--%>
            <%--onSubmit: function () {--%>
                <%--parent.$.messager.progress({--%>
                    <%--title: '提示',--%>
                    <%--text: '数据处理中，请稍后....'--%>
                <%--});--%>
                <%--var isValid = $(this).form('validate');--%>
                <%--if (!isValid) {--%>
                    <%--parent.$.messager.progress('close');--%>
                <%--}--%>
                <%--return isValid;--%>
            <%--},--%>
            <%--success: function (result) {--%>
                <%--parent.$.messager.progress('close');--%>
                <%--result = $.parseJSON(result);--%>
                <%--if (result && isSuccess(result.result)) {--%>
                    <%--parent.$.modalDialog.openner_treeGrid.datagrid('getPager').pagination('select');//之所以能在这里调用到parent.$.modalDialog.openner_treeGrid这个对象，是因为role.jsp页面预定义好了--%>
                    <%--parent.$.modalDialog.handler.dialog('close');--%>
                <%--}--%>
            <%--}--%>
        <%--});--%>
        addValidateOldName($('#deptName'), "uniqueDeptName");
    });
</script>
<var id="deptIdFrom" style="display: none">${deptId}</var>

<div class="easyui-layout" data-options="fit:true,border:false">
    <div data-options="region:'center',border:false" title="" style="overflow: hidden;">
        <form id="form" method="post">
            <table class="table table-hover table-condensed">
                <tr>
                    <th>编号</th>
                    <td><input id="deptId" name="id" type="text" class="span2"  readonly="readonly" ></td>
                </tr>
                <tr>
                    <th>上级业务单元</th>
                    <td><input name="company" id="company" type="text" class="easyui-validatebox span2" data-options="required:true" value="中钢在线" readonly></td>
                </tr>
                <tr>
                    <th>上级业务单元代码</th>
                    <td><input name="companyNo" id="companyNo" type="text" class="easyui-validatebox span2" data-options="required:true" value="ZGZX" readonly></td>
                </tr>
                <tr>
                    <th>部门名称</th>
                    <td><input name="deptName" id="deptName" type="text" class="easyui-validatebox span2"
                               data-options="required:true" value=""></td>
                </tr>
                <tr>
                    <th>状态:</th>
                    <td><select id="status" name="status" data-options="required:true">
                    </select></td>
                </tr>
                <tr>
                    <th>业务单元类型</th>
                    <td><input name="deptType" id="deptType" type="text" class="easyui-validatebox span2"
                               data-options="required:true" value="部门" readonly></td>
                </tr>
                <tr>
                    <th>开票限额</th>
                    <td><input name="amount" id="amount" type="text" class="easyui-validatebox span2 easyui-numberbox" value="" data-options="min:0,precision:0"></td>
                </tr>
            </table>
        </form>
    </div>
</div>